Conversation
This comment has been minimized.
This comment has been minimized.
| .withQuery(query) | ||
| .withExistingStatement(this) | ||
| .build() | ||
| .prepareAndExecute(callback); |
There was a problem hiding this comment.
Perhaps a nitpick, but if we run multiple queries with the same statement using execute we will only close one of the handles in the server.
Code for repro:
try (Connection connection = DriverManager.getConnection(jdbcUrl, properties);
Statement statement = connection.createStatement()) {
for (int i = 1; i <= n; i++) {
String sql = "SELECT " + i;
log("Executing: " + sql);
boolean isResultSet = statement.execute(sql);
if (isResultSet) {
try (ResultSet rs = statement.getResultSet()) {
// consume result set
}
} else {
System.out.println("Updated rows: " + statement.getUpdateCount());
}
}
}
A new prepared statement will be created on each query, but only one ClosePreparedStatement is sent to the server. I believe most Flight SQL servers are stateless and this won't be problematic in that scenario, but in case the server is holding some resources associated with the handle(s) of the prepared statement(s) that aren't closed there will be a leak.
Could we send the close after execution?
There was a problem hiding this comment.
Good catch. This issue existed before the refactor. I've created #1129 to be addressed separately
e49fea0 to
743dc87
Compare
* reduced number of requests for Statement * move meta orchestration * detect prepared statement
This reverts commit b57550f.
a667705 to
3a77376
Compare
Restore source-compatible exception declarations and map prepared-statement transition failures to SQLException.
Dispatch Avatica operations through package-private hooks and guard the public statement API surface.
Keep FlightEndpointDataQueue fail-fast while normalizing cancellation races inside the JDBC result-set path.
|
@xborder thanks for the update! I will do the review. |
What Changed
Statement.executeQuery/executeUpdateavoiding thePreparedStatementrequest flowStatement.execute(String)still flows through PreparedStatementCommandStatementUpdateorCommandStatemenQuerywithout doing a server callArrowFlightPreparedStatementArrowFlightStatementwith specific logic to handleStatementsArrowFlightMetaImpl.ArrowFlightMetaImplwas left it focused on orchestrationCloses #62.
This PR was assisted by AI